import Dialog from '@vant/weapp/dialog/dialog'

const app = getApp()

Page({
  data: {
    userInfo: {},
  },

  async logout() {
    await Dialog.confirm({
      title: '你确定退出？',
    })
    app.removeToken()
    app.removeRefreshToken()
    wx.redirectTo({
      url: '/pages/login/index',
    })
  },

  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },

  async onShow() {
    const res = await wx.http({
      method: 'get',
      url: '/userInfo',
    })
    this.setData({ userInfo: res.data })
  },
})
